package com.ycw.servlet.guoguo;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ycw.dao.HouseRepairDao;
import com.ycw.dao.impl.HouseRepairDaoImpl;

/**
 * Servlet implementation class DeleteHouseRepairDataByIdServlet
 */
@WebServlet("/deleteHouseRepairDataByIdServlet")
public class DeleteHouseRepairDataByIdServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);

	}

	/**
	 * 根据hr_id删除
	 */
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id = request.getParameter("hr_id");
		Integer hr_id = Integer.parseInt(id);
		System.out.println("请求成功");
		System.out.println("hr_id:" + hr_id);

		HouseRepairDao hrd = HouseRepairDaoImpl.getInstance();
		/**
		 * 删除成功为true
		 */
		boolean flage = hrd.deleteHouseRepairDataById(hr_id);
		String resJSON = JSON.toJSONString(flage);
		PrintWriter out = response.getWriter();
		out.write(resJSON);
		out.close();
	}

}
